package com.yy.excel_port;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author MinghuaChen
 * @since 2025/2/18 21:15
 */
public class ExcelExporter {

    private static void writeBatchToExcel(String filePath) {
        // 这里可以做成异步的 先不做了
        // 分批次
        for (int i = 0; i < 1; i++) {
             //查询数据
            List<DataRow> data = TestDataGenerator.generateData(1000);
            ExcelWriterBuilder writerBuilder = EasyExcel.write(filePath, DataRow.class);
            // 写入
            writerBuilder.sheet().doWrite(data);
        }
        // 上传到oss

        // 删除本地文件

    }

    public static void main(String[] args) {
        // 异步导出数据
        writeBatchToExcel("data_output.xlsx");
        // 等待
        try {
            System.in.read();
        } catch (Exception e) {

        }

    }
}
